<template>
  <div>
    <el-dialog
      :title="this.$t('common.modify')"
      :visible.sync="Visible"
      width="80%"
      :close-on-click-modal="false"
      @close="cancel"
    >
      <div class="dialogBox">
        <div class="dialogBoxItem">
          <div style="width:24%;" class="dialogBoxItemRow">
            <div class="title">
              <div class="RequiredRowTip">*</div>
              {{$t('LineManagementLang.Line_name')}}:
            </div>
            <div class="contant">
              <el-input
                disabled
                ref="name_current"
                :placeholder="$t('common.input_plactholder')"
                v-model="data.name_current"
              ></el-input>
              <img  @click="setLineName" style="width:36px;marginLeft: 5px;cursor: pointer;" src="@/assets/img/设置.png" alt="">
            </div>
          </div>
          <div style="width:24%;" class="dialogBoxItemRow">
            <div class="title">
              <div class="RequiredRowTip">*</div>
              {{$t('LineManagementLang.Business_type')}}:
            </div>
            <div class="contant">
              <el-select
                ref="type"
                filterable
                @blur="handleBlur('type', $event)"
                @change="handleChang('type')"
                v-model="data.type"
                :placeholder="$t('common.select_plactholder')"
              >
                <el-option
                  v-for="item in options_business"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </div>
          </div>
          <div style="width:24%;" class="dialogBoxItemRow">
            <div class="title">
              <div class="RequiredRowTip">*</div>
              {{$t('LineManagementLang.Inherit_Line')}}:
            </div>
            <div class="contant">
              <el-select
                ref="parent_id"
                filterable
                @blur="handleBlur('parent_id', $event)"
                @change="handleChang('parent_id')"
                v-model="data.parent_id"
                :placeholder="$t('common.select_plactholder')"
              >
                <el-option
                  v-for="item in options_line"
                  :key="item.id"
                  :label="item.name_current"
                  :value="item.id"
                >
                </el-option>
              </el-select>
              <div :style="{marginLeft: '5px',whiteSpace: 'nowrap',color: data.parent_id!=0?'#62afff':'#8f9193',cursor: data.parent_id!=0?'pointer':'not-allowed'}" @click="details">{{$t('common.details')}}</div>
            </div>
          </div>
          <div style="width:24%;" class="dialogBoxItemRow">
            <div class="title">
              {{$t('LineManagementLang.Partners')}}:
            </div>
            <div class="contant">
              <el-select
                :disabled="data.parent_id!=0"
                filterable
                v-model="data.enterprise"
                @change="getAddress(false)"
                :placeholder="$t('common.select_plactholder')"
              >
                <el-option
                  v-for="item in options_Partners"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </div>
          </div>
        </div>
      </div>
      <div class="dialogBox">
        <div class="dialogBoxItem">
          <div style="width:24%" class="dialogBoxItemRow">
            <div class="title">
              <div class="RequiredRowTip">*</div>
              {{$t('LineManagementLang.Origin')}}:
            </div>
            <div class="contant">
              <Multiselect
                :isDoubleJudge="true"
                :select_label="'name_current'"
                ref="start_local"
                :modalName="'start_local'"
                :select_model="data.start_local"
                :select_options="options_str"
                @selectBlur="selectBlur('start_local')"
                @selectChang="MultiselectChange"
              >
              </Multiselect>
              <div :style="{marginLeft: '5px',whiteSpace: 'nowrap',color: data.parent_id!=0?'#62afff':'#8f9193',cursor: data.parent_id!=0?'pointer':'not-allowed'}" @click="setCity('start')">{{$t('LineManagementLang.configuration')}}</div>
            </div>
          </div>
          <div style="width:24%" class="dialogBoxItemRow">
            <div class="title">
              {{$t('LineManagementLang.country')}}:
            </div>
            <div class="contant">
              <el-select
                v-if="data.parent_id===0"
                ref="country"
                filterable
                @blur="handleBlur('country', $event)"
                @change="handleChang('country')"
                v-model="data.country"
                :placeholder="$t('common.select_plactholder')"
              >
                <el-option
                  v-for="item in options_country"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
              <el-input
                v-else
                disabled
                v-model="data.country_name"
              ></el-input>
            </div>
          </div>
          <div style="width:24%" class="dialogBoxItemRow">
            <div class="title">
              <div class="RequiredRowTip">*</div>
              {{$t('LineManagementLang.destination')}}:
            </div>
            <div class="contant">
              <Multiselect
                :isDoubleJudge="true"
                :select_label="'name_current'"
                ref="target_local"
                :modalName="'target_local'"
                :select_model="data.target_local"
                :select_options="options_end"
                @selectBlur="selectBlur('target_local')"
                @selectChang="MultiselectChange"
              >
              </Multiselect>
              <div :style="{marginLeft: '5px',whiteSpace: 'nowrap',color: data.parent_id!=0?'#62afff':'#8f9193',cursor: data.parent_id!=0?'pointer':'not-allowed'}" @click="setCity('target')">{{$t('LineManagementLang.configuration')}}</div>
            </div>
          </div>
          <div style="width:24%" class="dialogBoxItemRow">
            <div class="title">
              <div class="RequiredRowTip">*</div>
              {{$t('LineManagementLang.IsBrand')}}:
            </div>
            <div class="contant">
              <el-select
                :disabled="data.type!=1"
                filterable
                v-model="data.is_brand"
                :placeholder="$t('common.select_plactholder')"
              >
                <el-option
                  v-for="item in options_IsBrand"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </div>
          </div>
        </div>
        <div class="dialogBoxItem">
          <div style="width:24%" class="dialogBoxItemRow">
            <div class="title">
              <div class="RequiredRowTip">*</div>
              {{$t('LineManagementLang.Delivery_method')}}:
            </div>
            <div class="contant">
              <el-select
                :disabled="data.parent_id!==0"
                ref="dispatch_type"
                multiple
                @blur="handleBlur('dispatch_type', $event)"
                @change="handleChang('dispatch_type')"
                v-model="data.dispatch_type"
                :placeholder="$t('common.select_plactholder')"
              >
                <el-option
                  v-for="item in options_delivery"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </div>
          </div>
          <div style="width:24%" class="dialogBoxItemRow">
            <div class="title">
              <div class="RequiredRowTip">*</div>
              {{$t('LineManagementLang.Pickup_method')}}:
            </div>
            <div class="contant">
              <el-select
                :disabled="data.parent_id!==0"
                ref="pickup_type"
                multiple
                @blur="handleBlur('pickup_type', $event)"
                @change="handleChang('pickup_type')"
                v-model="data.pickup_type"
                :placeholder="$t('common.select_plactholder')"
              >
                <el-option
                  v-for="item in options_pickup"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </div>
          </div>
          <div style="width:24%" class="dialogBoxItemRow">
            <div class="title">
              <div class="RequiredRowTip">*</div>
              {{$t('LineManagementLang.weight_type')}}:
            </div>
            <div class="contant">
              <el-select
                :disabled="data.parent_id!==0"
                ref="weight_type"
                filterable
                @blur="handleBlur('weight_type', $event)"
                @change="handleChang('weight_type')"
                v-model="data.weight_type"
                :placeholder="$t('common.select_plactholder')"
              >
                <el-option
                  v-for="item in options_weight_type"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </div>
          </div>
          <div style="width:24%" class="dialogBoxItemRow">
            <div class="title">
              {{$t('LineManagementLang.Bubble_weight')}}:
            </div>
            <div class="contant">
              <el-input-number
                :disabled="data.weight_type!=3||data.parent_id!==0"
                controls-position="right"
                size="small" 
                :min="1" 
                :precision="0"
                v-model="data.weight_calc_rule">
              </el-input-number>
            </div>
          </div>
        </div>
        <div class="dialogBoxItem">
          <div style="width:24%" class="dialogBoxItemRow">
            <div class="title">
              <div class="RequiredRowTip">*</div>
              {{$t('LineManagementLang.lifting_weight')}}:
            </div>
            <div class="contant">
              <el-input-number
                :disabled="data.parent_id!==0"
                controls-position="right"
                size="small" 
                ref="start_weight" 
                @blur="handleBlur('start_weight', $event)" 
                @focus="handleFocus($event)" 
                :min="0"  
                :precision="1"
                v-model="data.start_weight">
              </el-input-number>
            </div>
          </div>
          <div style="width:24%" class="dialogBoxItemRow">
            <div class="title">
              <div class="RequiredRowTip">*</div>
              {{$t('LineManagementLang.extension_weight')}}:
            </div>
            <div class="contant">
              <el-input-number
                :disabled="data.parent_id!==0"
                controls-position="right"
                size="small" 
                ref="renew_weight" 
                @blur="handleBlur('renew_weight', $event)" 
                @focus="handleFocus($event)" 
                :min="0"  
                :precision="1"
                v-model="data.renew_weight">
              </el-input-number>
            </div>
          </div>
          <div style="width:24%" class="dialogBoxItemRow">
            <div class="title">
              <div class="RequiredRowTip">*</div>
              {{$t('LineManagementLang.lifting_volume')}}:
            </div>
            <div class="contant">
              <el-input-number
                :disabled="data.parent_id!==0"
                controls-position="right"
                size="small" 
                ref="start_volume" 
                @blur="handleBlur('start_volume', $event)" 
                @focus="handleFocus($event)" 
                :min="0"  
                :precision="5"
                v-model="data.start_volume">
              </el-input-number>
            </div>
          </div>
          <div style="width:24%" class="dialogBoxItemRow">
            <div class="title">
              <div class="RequiredRowTip">*</div>
              {{$t('LineManagementLang.extension_volume')}}:
            </div>
            <div class="contant">
              <el-input-number
                :disabled="data.parent_id!==0"
                controls-position="right"
                size="small" 
                ref="renew_volume" 
                @blur="handleBlur('renew_volume', $event)" 
                @focus="handleFocus($event)" 
                :min="0"  
                :precision="5"
                v-model="data.renew_volume">
              </el-input-number>
            </div>
          </div>
        </div>
        <div class="dialogBoxItem">
          <div style="width:24%;flex-direction: row;" class="dialogBoxItemRow">
            <div class="title">
              <div class="RequiredRowTip">*</div>
              {{$t('LineManagementLang.Line_Pic')}}:
            </div>
            <div class="contant">
              <UploadImg
                :maxSize="100"
                ref="logo"
                @FileList="setFileList"
              ></UploadImg>
            </div>
          </div>
           <div style="width:24%;" class="dialogBoxItemRow">
            <div class="title">
              <div class="RequiredRowTip">*</div>
              {{$t('LineManagementLang.Order_prefix')}}:
            </div>
            <div class="contant">
              <el-input
                :disabled="data.parent_id!=0"
                :placeholder="$t('common.input_plactholder')"
                v-model="data.order_prefix"
              ></el-input>
            </div>
          </div>
          <div style="width:24%;" class="dialogBoxItemRow">
            <div class="title">
              <div class="RequiredRowTip">*</div>
              {{$t('LineManagementLang.Package_prefix')}}:
            </div>
            <div class="contant">
              <el-input
                :disabled="data.parent_id!=0"
                :placeholder="$t('common.input_plactholder')"
                v-model="data.package_prefix"
              ></el-input>
            </div>
          </div>
          <div style="width:24%" class="dialogBoxItemRow">
            <div class="title">
              <div class="RequiredRowTip">*</div>
              {{$t('LineManagementLang.Line_Text')}}:
            </div>
            <div class="contant">
              <el-input
                disabled
                ref="intro_current"
                :placeholder="$t('common.input_plactholder')"
                v-model="data.intro_current"
              ></el-input>
              <img  @click="setLineText" style="width:36px;marginLeft: 5px;cursor: pointer;" src="@/assets/img/设置.png" alt="">
            </div>
          </div>
        </div>
        <div class="dialogBoxItem">
          <div style="width:24%" class="dialogBoxItemRow">
            <div class="title">
              <div class="RequiredRowTip">*</div>
              {{$t('LineManagementLang.payment_method')}}:
            </div>
            <div class="contant">
              <el-select
                v-if="data.type!==1"
                ref="pay_type"
                filterable
                @blur="handleBlur('pay_type', $event)"
                @change="handleChang('pay_type')"
                v-model="data.pay_type"
                :placeholder="$t('common.select_plactholder')"
              >
                <el-option
                  v-for="item in options_payment"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
              <el-switch
                v-else
                v-model="data.pay_type_flag"
                active-color="#26BD00"
                inactive-color="#c0c4cc"
                :active-value='1'
                :inactive-value='0'
                >
              </el-switch>
            </div>
          </div>
          <div style="width:75%;" class="dialogBoxItemRow">
            <div class="title">
              {{$t('LineManagementLang.Line_tip')}}:
            </div>
            <div class="contant">
              <el-input
                disabled
                ref="tip_current"
                :placeholder="$t('common.input_plactholder')"
                v-model="data.tip_current"
              ></el-input>
              <img  @click="setLinePrompt" style="width:36px;marginLeft: 5px;cursor: pointer;" src="@/assets/img/设置.png" alt="">
            </div>
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="cancel" size="small">{{$t('common.cancel')}}</el-button>
        <el-button type="primary" @click="next_step" size="small"
          >{{$t('LineManagementLang.next_step')}}</el-button
        >
      </span>
      
    </el-dialog>
    <SetLineName
      @success="success_lineName"
      ref="setLineName"
    ></SetLineName>
    <SetLineText
      @success="success_lineText"
      ref="setLineText"
    ></SetLineText>
    <SetLinePrompt
      @success="success_linePrompt"
      ref="setLinePrompt"
    ></SetLinePrompt>
    <DetailsTwo
      @next_step="next_step_details"
      ref="details"
    ></DetailsTwo>
    <SetCity
      @success="SetCitySuccess"
      ref="setCity"
    ></SetCity>
  </div>
</template>

<script>
import SetLineName from "./LineManagement_setLineName";
import SetLineText from "./LineManagement_setLineText";
import SetLinePrompt from "./LineManagement_setLinePrompt";
import DetailsTwo from "./LineManagement_details_two";
import UploadImg from "../../components/common/upload_Img";
import SetCity from "./LineManagement_setCity";
export default {
  components: {
    SetLineName,
    SetLineText,
    SetLinePrompt,
    DetailsTwo,
    UploadImg,
    SetCity,
  },
  props: {
    // 接收绑定参数
    
  },
  data() {
    return {
      Visible: false,
      id:'',
      data: {},
      options_Partners:[],
      options_business:[],
      options_line:[],
      start_option_arr:[],//始发的
      end_option_arr_express:[],//目的地（快递）
      end_option_arr_delivery:[],//目的地（快运）
      options_str:[],
      options_end:[],
      options_country:[],
      options_IsBrand:[],
      options_delivery:[],   
      options_pickup:[],   
      options_payment:[],
      options_weight_type:[],
      confirmTrue: true, //确定按钮保护
    };
  },
  created() {
   
  },
  mounted() {},
  watch: {},
  methods: {
    init(data) {
      this.options_str =[]
      this.options_end =[]
      this.getOptions()
      this.id=data.id
      this.Visible = true;
    },
    //获取单条
    getData() {
      this.$get("lineInfo", { id: this.id }).then((res) => {
        this.data = res.data;
        this.data.start_local=this.strToArr(res.data.start_local)
        this.data.hide_start_local=res.data.hide_start_local
        this.data.hide_target_local=res.data.hide_target_local
        this.data.target_local=this.strToArr(res.data.target_local)
        this.data.dispatch_type=this.strToArr(res.data.dispatch_type)
        this.data.pickup_type=this.strToArr(res.data.pickup_type)
        // this.filterAddres()
        this.$get("parentLines", {type:this.data.type}).then((res) => {
          this.options_line = res.data;
          this.options_line.unshift({id:0,name_current:this.$t('common.not_have')})
          this.getAddress(true)
        });
        this.$refs.logo.setImageUrl(this.$baseUrl+res.data.logo)
      });
    },
    setCity(type){
      if(this.data.parent_id!=0){
        let parent_line_str=[]
        let parent_line_end=[]
        let arr=this.options_line.filter(item=>{return item.id===this.data.parent_id})
        if(arr.length>0){
          parent_line_str =JSON.parse(JSON.stringify(arr[0].start_local_arr))
          parent_line_end =JSON.parse(JSON.stringify(arr[0].target_local_arr))
        }
        if(type=='start'){
          this.$refs.setCity.init('start_option_arr',this.start_option_arr,parent_line_str)
        }else if(type=='target'){
          if(this.data.type===0){
            this.$refs.setCity.init('end_option_arr_express',this.end_option_arr_express,parent_line_end)
          }else{
            this.$refs.setCity.init('end_option_arr_delivery',this.end_option_arr_delivery,parent_line_end)
          }
        }
      }
    },
    SetCitySuccess(list,type){
      if(type=='start_option_arr'){
        this.start_option_arr=list
      }else if(type=='end_option_arr_express'){
        this.end_option_arr_express=list
      }else if(type=='end_option_arr_delivery'){
        this.end_option_arr_delivery=list
      }
      let arr=this.options_line.filter(item=>{return item.id===this.data.parent_id})
      if(arr.length>0){
        this.options_str =JSON.parse(JSON.stringify(arr[0].start_local_arr))
        this.options_end =JSON.parse(JSON.stringify(arr[0].target_local_arr))
        this.options_str.push(...this.start_option_arr.filter(ele=>{return !!ele.bind_id}))
        if(this.data.type===0){
          this.options_end.push(...this.end_option_arr_express.filter(ele=>{return !!ele.bind_id}))
        }else{
          this.options_end.push(...this.end_option_arr_delivery.filter(ele=>{return !!ele.bind_id}))
        }
      }
    },
    strToArr(data){
      let arr=data.split(',')
      return arr.map(item=>{return Number(item)})
    },
    //获取下拉单数据
    getOptions(){

      this.$get("lineSysItems").then((res) => {
        this.options_business = res.data.business_type;
        this.options_IsBrand = res.data.is_brand;
        this.options_delivery = res.data.dispatch_type;
        this.options_pickup = res.data.pickup_type;
        this.options_payment = res.data.line_pay_type;
        this.options_weight_type = res.data.line_weight_type;
        this.getData();
      });
      this.$get("addressLibraryList", {parent_id:-1}).then((res) => {
        this.options_country = res.data;
      });
      this.$get("getEnterprise").then((res) => {
        this.options_Partners = res.data;
      });
    },
    getAddress(noClear){
      // 是否不清理已选地址
      if(!noClear){
        console.log(!noClear)
        this.data.start_local=""
        this.data.hide_start_local=""
        this.data.hide_target_local=""
        this.data.target_local=""
      }
      let obj={target_country:this.data.country}
      if(!!this.data.enterprise){
        obj.enterprise_id=this.data.enterprise
      }
      this.$get("visibleAddress",obj).then((res) => {
        this.start_option_arr = res.data.start_local;
        this.start_option_arr.forEach(el=>{
          let key=this.data.start_bind_address.findIndex(ite=>{return ite.id==el.id})
          if(this.data.start_bind_address.length>0&&key!=-1){
            el.bind_id=this.data.start_bind_address[key].bind_id
          }else{
            el.bind_id=''
          }
          el.isTrue=true
        })
        this.end_option_arr_express = res.data.target_local;
        this.end_option_arr_express.forEach(el=>{
          let key=this.data.target_bind_address.findIndex(ite=>{return ite.id==el.id})
          if(this.data.target_bind_address.length>0&&key!=-1){
            el.bind_id=this.data.target_bind_address[key].bind_id
          }else{
            el.bind_id=''
          }
          el.isTrue=true
        })
        this.end_option_arr_delivery = res.data.main_local;
        this.end_option_arr_delivery.forEach(el=>{
          let key=this.data.target_bind_address.findIndex(ite=>{return ite.id==el.id})
          if(this.data.target_bind_address.length>0&&key!=-1){
            el.bind_id=this.data.target_bind_address[key].bind_id
          }else{
            el.bind_id=''
          }
          el.isTrue=true
        })
        this.filterAddres()
      });
    },
    filterAddres(){
      if(this.data.parent_id==0){
          this.options_str=this.start_option_arr
          if(this.data.type===0){
            this.options_end=this.end_option_arr_express
          }else{
            this.options_end=this.end_option_arr_delivery
          }
        }else{
          // this.options_str =this.data.start_local_arr
          // this.options_end =this.data.target_local_arr
          let arr=this.options_line.filter(item=>{return item.id===this.data.parent_id})
          if(arr.length>0){
            // this.data.start_local=this.strToArr(arr[0].start_local)
            // this.data.hide_start_local=arr[0].hide_start_local
            // this.data.hide_target_local=arr[0].hide_target_local
            // this.data.target_local=this.strToArr(arr[0].target_local)
            this.options_str =JSON.parse(JSON.stringify(arr[0].start_local_arr))
            this.options_end =JSON.parse(JSON.stringify(arr[0].target_local_arr))
            this.options_str.push(...this.start_option_arr.filter(ele=>{return !!ele.bind_id}))
            if(this.data.type===0){
              this.options_end.push(...this.end_option_arr_express.filter(ele=>{return !!ele.bind_id}))
            }else{
              this.options_end.push(...this.end_option_arr_delivery.filter(ele=>{return !!ele.bind_id}))
            }
          }
        }
        if(this.options_str.length>0){
          this.options_str.forEach(item=>{
            // let key=this.data.start_bind_address.findIndex(ite=>{return ite.id==item.id})
            // if(this.data.start_bind_address.length>0&&key!=-1){
            //   item.bind_id=this.data.start_bind_address[key].bind_id
            // }else{
            //   item.bind_id=''
            // }
            let arr=this.data.hide_start_local.split(',').filter(el=>{return el==item.id})
            if(arr.length>0){
              item.isTrue=false
            }
          })
        }
        if(this.options_end.length>0){
          this.options_end.forEach(item=>{
            // let key=this.data.target_bind_address.findIndex(ite=>{return ite.id==item.id})
            // if(this.data.target_bind_address.length>0&&key!=-1){
            //   item.bind_id=this.data.target_bind_address[key].bind_id
            // }else{
            //   item.bind_id=''
            // }
            let arr=this.data.hide_target_local.split(',').filter(el=>{return el==item.id})
            if(arr.length>0){
              item.isTrue=false
            }
          })
        }
        console.log(this.options_str)
    },
    details(){
      if(this.data.parent_id!=0){
        this.$refs.details.init({id:this.data.parent_id})
      }
    },
    //详情功能点击下一步后的操作
    next_step_details(){
      this.$emit("details_next_step");
    },
    setLineName(){
      let obj={
        Line_name_zh:this.data.name,
        Line_name_en:this.data.name_en,
        Line_name_ru:this.data.name_ru,
      }
      this.$refs.setLineName.init(obj)
    },
    success_lineName(obj){
      this.data.name=obj.Line_name_zh
      this.data.name_en=obj.Line_name_en
      this.data.name_ru=obj.Line_name_ru
      let langObj=JSON.parse(localStorage.getItem('language'))
      if(langObj.lang=='zh'){
        this.data.name_current=obj.Line_name_zh
      }else if(langObj.lang=='en'){
        this.data.name_current=obj.Line_name_en
      }else if(langObj.lang=='ru'){
        this.data.name_current=obj.Line_name_ru
      }
      this.$refs.name_current.$el.childNodes[1].style.border='1px solid #E0E3E9'
    },
    setLineText(){
      let obj={
        Line_text_zh:this.data.intro,
        Line_text_en:this.data.intro_en,
        Line_text_ru:this.data.intro_ru,
      }
      this.$refs.setLineText.init(obj)
    },
    success_lineText(obj){
      this.data.intro=obj.Line_text_zh
      this.data.intro_en=obj.Line_text_en
      this.data.intro_ru=obj.Line_text_ru
      let langObj=JSON.parse(localStorage.getItem('language'))
      if(langObj.lang=='zh'){
        this.data.intro_current=obj.Line_text_zh
      }else if(langObj.lang=='en'){
        this.data.intro_current=obj.Line_text_en
      }else if(langObj.lang=='ru'){
        this.data.intro_current=obj.Line_text_ru
      }
      this.$refs.intro_current.$el.childNodes[1].style.border='1px solid #E0E3E9'
    },
    setLinePrompt(){
      let obj={
        Line_tip_zh:this.data.tip,
        Line_tip_en:this.data.tip_en,
        Line_tip_ru:this.data.tip_ru,
      }
      this.$refs.setLinePrompt.init(obj)
    },
    success_linePrompt(obj){
      this.data.tip=obj.Line_tip_zh
      this.data.tip_en=obj.Line_tip_en
      this.data.tip_ru=obj.Line_tip_ru
      let langObj=JSON.parse(localStorage.getItem('language'))
      if(langObj.lang=='zh'){
        this.data.tip_current=obj.Line_tip_zh
      }else if(langObj.lang=='en'){
        this.data.tip_current=obj.Line_tip_en
      }else if(langObj.lang=='ru'){
        this.data.tip_current=obj.Line_tip_ru
      }
      this.$refs.tip_current.$el.childNodes[1].style.border='1px solid #E0E3E9'
    },
    setFileList(val){
      this.data.logo=val.raw
      if(!!this.data.logo){
        this.$refs.logo.$el.getElementsByClassName('el-upload')[0].style.border='1px solid #E0E3E9'
      }
    },
    // 提交
    next_step() {
      //是否有空值必选项标识
      let type = true;
      //输入框判断是否有值
      if(!this.data.name_current){
        this.$refs.name_current.$el.childNodes[1].style.border='1px solid red'
        type=false
      }
      if (!this.data.type&&this.data.type!==0) {
        this.$refs.type.$el.childNodes[1].childNodes[1].style.border =
          "1px solid red";
        type = false;
      }
      if (!this.data.parent_id&&this.data.parent_id!==0) {
        this.$refs.parent_id.$el.childNodes[1].childNodes[1].style.border =
          "1px solid red";
        type = false;
      }
      if (!this.data.start_local||this.data.start_local.length==0) {
        this.$refs.start_local.$el.childNodes[0].childNodes[1].childNodes[1].style.border =
          "1px solid red";
        type = false;
      }
      if (!this.data.country&&this.data.country!==0) {
        this.$refs.country.$el.childNodes[1].childNodes[1].style.border =
          "1px solid red";
        type = false;
      }
      if (!this.data.target_local||this.data.target_local.length==0) {
        this.$refs.target_local.$el.childNodes[0].childNodes[1].childNodes[1].style.border =
          "1px solid red";
        type = false;
      }
      if (!this.data.dispatch_type&&this.data.dispatch_type!==0) {
        this.$refs.dispatch_type.$el.childNodes[1].childNodes[1].style.border =
          "1px solid red";
        type = false;
      }
      if (!this.data.pickup_type&&this.data.pickup_type!==0) {
        this.$refs.pickup_type.$el.childNodes[1].childNodes[1].style.border =
          "1px solid red";
        type = false;
      }
      if( this.data.type!=1){
        if (!this.data.pay_type&&this.data.pay_type!==0) {
          this.$refs.pay_type.$el.childNodes[1].childNodes[1].style.border =
            "1px solid red";
          type = false;
        }
      }
      if (!this.data.weight_type&&this.data.weight_type!==0) {
        this.$refs.weight_type.$el.childNodes[1].childNodes[1].style.border =
          "1px solid red";
        type = false;
      }
      if(!this.data.start_weight){
        this.$refs.start_weight.$el.childNodes[2].childNodes[1].style.border='1px solid red'
        type=false
      }
      if(!this.data.renew_weight){
        this.$refs.renew_weight.$el.childNodes[2].childNodes[1].style.border='1px solid red'
        type=false
      }
      if(!this.data.start_volume){
        this.$refs.start_volume.$el.childNodes[2].childNodes[1].style.border='1px solid red'
        type=false
      }
      if(!this.data.renew_volume){
        this.$refs.renew_volume.$el.childNodes[2].childNodes[1].style.border='1px solid red'
        type=false
      }
      if(!this.data.intro_current){
        this.$refs.intro_current.$el.childNodes[1].style.border='1px solid red'
        type=false
      }
      if(!this.data.logo){
        this.$refs.logo.$el.getElementsByClassName('el-upload')[0].style.border='1px solid red'
        type=false
      }
      if (type && this.confirmTrue) {
        this.confirmTrue=false
        window.setTimeout(()=>{
          this.confirmTrue=true
        },1000);
        let params = new FormData();
        params.append("id", this.id);
        params.append("name", this.data.name);
        params.append("name_en", this.data.name_en);
        params.append("name_ru", this.data.name_ru);
        params.append("enterprise", this.data.enterprise);
        params.append("type", this.data.type);
        params.append("parent_id", this.data.parent_id);
        params.append("start_local", this.data.start_local);
        params.append("hide_start_local", this.data.hide_start_local);
        params.append("hide_target_local", this.data.hide_target_local);
        params.append("country", this.data.country);
        params.append("target_local", this.data.target_local);
        let start_bind_address=[]
        this.options_str.forEach(item=>{
          if(this.data.start_local.findIndex(el=>{return el==item.id})!=-1){
            start_bind_address.push({id:item.id,bind_id:!!item.bind_id?item.bind_id:''})
          }
        })
        params.append("start_bind_address", JSON.stringify(start_bind_address));
        let target_bind_address=[]
        this.options_end.forEach(item=>{
          if(this.data.target_local.findIndex(el=>{return el==item.id})!=-1){
            target_bind_address.push({id:item.id,bind_id:!!item.bind_id?item.bind_id:''})
          }
        })
        params.append("target_bind_address", JSON.stringify(target_bind_address));
        params.append("is_brand", this.data.is_brand);
        params.append("dispatch_type", this.data.dispatch_type);
        params.append("pickup_type", this.data.pickup_type);
        if(this.data.type!==1){
          params.append("pay_type", this.data.pay_type);
        }else{
          params.append("pay_type_flag", this.data.pay_type_flag);
        }
        params.append("weight_type", this.data.weight_type);
        params.append("weight_calc_rule", this.data.weight_calc_rule);
        params.append("start_weight", this.data.start_weight);
        params.append("renew_weight", this.data.renew_weight);
        params.append("start_volume", this.data.start_volume);
        params.append("renew_volume", this.data.renew_volume);
        params.append("logo", this.data.logo);
        params.append("order_prefix", this.data.order_prefix);
        params.append("package_prefix", this.data.package_prefix);
        params.append("intro", this.data.intro);
        params.append("intro_en", this.data.intro_en);
        params.append("intro_ru", this.data.intro_ru);
        params.append("tip", this.data.tip);
        params.append("tip_en", this.data.tip_en);
        params.append("tip_ru", this.data.tip_ru);
        this.$postForm("editLine", params).then((res) => {
          this.confirmTrue = true;
          if(res.success){
            this.$message.success(res.msg);
            this.$emit("next_step",res.data);
            this.cancel()
          }
        });
      }
    },
    //取消
    cancel() {
      this.$refs.logo.handleRemove()
      this.data = {};
      this.Visible = false;
      
      let dom = document.getElementsByClassName("el-input__inner");
      for (let i = 0; i < dom.length; i++) {
         dom[i].style.border = "1px solid #E0E3E9";
      }
    },
    //输入框、下拉框失去焦点边框变色
    handleBlur(name, event) {
        if (this.data[name] === ""||!this.data[name]&&this.data[name]!==0) {
          event.target.style.border = "1px solid red";
        }
    },
    //输入框、下拉框获取焦点边框变色
    handleFocus(event) {
      event.target.style.border = "1px solid #E0E3E9";
    },
    //自定义多选下拉框
    selectBlur(name){
      if(this.data.parent_id==0){
        if (this.data[name] === ""||!this.data[name]&&this.data[name]!==0) {
          this.$refs[name].$el.childNodes[0].childNodes[1].childNodes[1].style.border ="1px solid red";
        }
      }
    },
    MultiselectChange(obj){
      this.data[obj.name]=obj.value
      if(obj.name=='start_local'){
        this.data.hide_start_local=obj.hideStr
      }
      if(obj.name=='target_local'){
        this.data.hide_target_local=obj.hideStr
      }
      if (this.data[obj.name].length===0) {
        this.$refs[obj.name].$el.childNodes[0].childNodes[1].childNodes[1].style.border = "1px solid red";
      }else{
        this.$refs[obj.name].$el.childNodes[0].childNodes[1].childNodes[1].style.border ="1px solid #E0E3E9 ";
      }
    },
    //下拉框有值后边框变色
    handleChang(data) {
      if(data==="type"){
        this.$get("parentLines", {type:this.data.type}).then((res) => {
          this.options_line = res.data;
          this.options_line.unshift({id:0,name_current:this.$t('common.not_have')})
        });
        this.data.parent_id=''
        if(this.data.parent_id==0){
          this.start_option_arr.forEach(el=>{
            el.bind_id=''
          })
          this.end_option_arr_express.forEach(el=>{
            el.bind_id=''
          })
          this.end_option_arr_delivery.forEach(el=>{
            el.bind_id=''
          })
          this.options_str=this.start_option_arr
          if(this.data.type===0){
            this.options_end=this.end_option_arr_express
          }else{
            this.options_end=this.end_option_arr_delivery
          }
        }
      }
      if(data==="parent_id"){
        this.start_option_arr.forEach(el=>{
          el.bind_id=''
        })
        this.end_option_arr_express.forEach(el=>{
          el.bind_id=''
        })
        this.end_option_arr_delivery.forEach(el=>{
          el.bind_id=''
        })
        let arr=this.options_line.filter(item=>{return item.id===this.data.parent_id})
        if(arr.length>0&&this.data.parent_id!==0){
          this.data.enterprise=0
          this.options_str =JSON.parse(JSON.stringify(arr[0].start_local_arr))
          this.options_end =JSON.parse(JSON.stringify(arr[0].target_local_arr))
          this.options_str.push(...this.start_option_arr.filter(ele=>{return !!ele.bind_id}))
          if(this.data.type===0){
            this.options_end.push(...this.end_option_arr_express.filter(ele=>{return !!ele.bind_id}))
          }else{
            this.options_end.push(...this.end_option_arr_delivery.filter(ele=>{return !!ele.bind_id}))
          }
          this.data.start_local=this.strToArr(arr[0].start_local)
          this.data.hide_start_local=arr[0].hide_start_local
          this.data.hide_target_local=arr[0].hide_target_local
          this.data.country=arr[0].country
          this.data.country_name=arr[0].country_name
          this.data.target_local=this.strToArr(arr[0].target_local)
          this.data.dispatch_type=this.strToArr(arr[0].dispatch_type)
          this.data.pickup_type=this.strToArr(arr[0].pickup_type)
          this.data.is_brand=arr[0].is_brand
          this.data.pay_type=arr[0].pay_type
          this.data.pay_type_flag=arr[0].pay_type_flag
          this.data.weight_type=arr[0].weight_type
          this.data.weight_calc_rule=arr[0].weight_calc_rule
          this.data.start_weight=arr[0].start_weight
          this.data.renew_weight=arr[0].renew_weight
          this.data.start_volume=arr[0].start_volume
          this.data.renew_volume=arr[0].renew_volume
          this.data.order_prefix=arr[0].order_prefix
          this.data.package_prefix=arr[0].package_prefix
          this.data.intro_current=arr[0].intro
          this.data.intro=arr[0].intro
          this.data.intro_en=arr[0].intro_en
          this.data.intro_ru=arr[0].intro_ru
          this.data.tip_current=arr[0].tip
          this.data.tip=arr[0].tip
          this.data.tip_en=arr[0].tip_en
          this.data.tip_ru=arr[0].tip_ru
          if(this.options_str.length>0){
            this.options_str.forEach(item=>{
              let arr=this.data.hide_start_local.split(',').filter(el=>{return el==item.id})
              if(arr.length>0){
                item.isTrue=false
              }
            })
          }
          if(this.options_end.length>0){
            this.options_end.forEach(item=>{
              let arr=this.data.hide_target_local.split(',').filter(el=>{return el==item.id})
              if(arr.length>0){
                item.isTrue=false
              }
            })
          }
          this.$refs.start_local.$el.childNodes[0].childNodes[1].childNodes[1].style.border ="1px solid #E0E3E9";
          if(this.data.parent_id===0){
            this.$refs.country.$el.childNodes[1].childNodes[1].style.border ="1px solid #E0E3E9";
          }
          this.$refs.target_local.$el.childNodes[0].childNodes[1].childNodes[1].style.border ="1px solid #E0E3E9";
          this.$refs.dispatch_type.$el.childNodes[1].childNodes[1].style.border ="1px solid #E0E3E9";
          this.$refs.pickup_type.$el.childNodes[1].childNodes[1].style.border ="1px solid #E0E3E9";
          if(this.data.type!==1){
            this.$refs.pay_type.$el.childNodes[1].childNodes[1].style.border ="1px solid #E0E3E9";
          }
          this.$refs.weight_type.$el.childNodes[1].childNodes[1].style.border='1px solid #E0E3E9'
          this.$refs.start_weight.$el.childNodes[2].childNodes[1].style.border='1px solid #E0E3E9'
          this.$refs.renew_weight.$el.childNodes[2].childNodes[1].style.border='1px solid #E0E3E9'
          this.$refs.start_volume.$el.childNodes[2].childNodes[1].style.border='1px solid #E0E3E9'
          this.$refs.renew_volume.$el.childNodes[2].childNodes[1].style.border='1px solid #E0E3E9'
          this.$refs.intro_current.$el.childNodes[1].style.border='1px solid #E0E3E9'
        }else{
          this.data.start_local=''
          this.data.hide_start_local=''
          this.data.hide_target_local=''
          this.data.country=''
          this.data.country_name=''
          this.data.target_local=''
          this.data.is_brand=''
          this.data.dispatch_type=''
          this.data.pickup_type=''
          this.data.pay_type=''
          this.data.weight_type=''
          this.data.weight_calc_rule=''
          this.data.start_weight=''
          this.data.renew_weight=''
          this.data.start_volume=''
          this.data.renew_volume=''
          this.data.intro_current=''
          this.data.intro=''
          this.data.intro_en=''
          this.data.intro_ru=''
          this.data.tip_current=''
          this.data.tip=''
          this.data.tip_en=''
          this.data.tip_ru=''
          this.options_str=this.start_option_arr
          if(this.data.type===0){
            this.options_end=this.end_option_arr_express
          }else{
            this.options_end=this.end_option_arr_delivery
          }
        }
      }
      if(data==="country"){
        this.getAddress(false)
      }
      if (this.data[data].length===0) {
        this.$refs[data].$el.childNodes[1].childNodes[1].style.border = "1px solid red";
      }else{
        this.$refs[data].$el.childNodes[1].childNodes[1].style.border ="1px solid #E0E3E9 ";
      }
    },
  },
};
</script>

<style scoped lang="less" >
/deep/ .el-dialog__wrapper{
  .el-dialog{
    min-width: 800px;
  }
}
</style>